﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace FaceSharp.Api.Types
{
    [Serializable]
    public class SignedRequest
    {
        /// <summary>
        /// A JSON object containing the locale string, country string and the age object (containing the min and max number range of the age) for the current user.
        /// </summary>
        [JsonProperty(PropertyName = "user")]
        public UserData User { get; set; }

        /// <summary>
        /// A JSON string containing the mechanism used to sign the request.
        /// </summary>
        [JsonProperty(PropertyName = "algorithm")]
        public string Algorithm { get; set; }

        /// <summary>
        /// A JSON number containing the Unix timestamp when the request was signed.
        /// </summary>
        [JsonProperty(PropertyName = "issued_at")]
        public long? IssuedAt { get; set; }

        /// <summary>
        ///  A JSON string containing the Facebook user identifier (UID) of the current user.
        /// </summary>
        [JsonProperty(PropertyName = "user_id")]
        public long? UserId { get; set; }

        /// <summary>
        /// A string you can pass to the Graph API to exchange for an Application Key.
        /// </summary>
        [JsonProperty(PropertyName = "code")]
        public string Code { get; set; }
        

        /// <summary>
        /// A JSON string that you can pass to the Graph API or the Legacy REST API.
        /// </summary>
        [JsonProperty(PropertyName = "oauth_token")]
        public string OAuthToken { get; set; }
        
        /// <summary>
        /// A JSON number containing the Unix timestamp when the oauth_token expires.
        /// </summary>
        [JsonProperty(PropertyName = "expires")]
        public long? Expires { get; set; }

        /// <summary>
        /// A JSON string containing the content of a query string parameter also called app_data. Usually specified when the application built the link to pass some data to itself. Only available if your app is an iframe loaded in a Page tab.
        /// </summary>
        [JsonProperty(PropertyName = "app_data")]
        public string AppData { get; set; }

        /// <summary>
        /// A JSON object containing the page id string, the liked boolean if the user has liked the page, the admin boolean if the user is an admin. Only available if your app is an iframe loaded in a Page tab.
        /// </summary>
        [JsonProperty(PropertyName = "page")]
        public PageData Page { get; set; }
        [Serializable]
        public class PageData
        {
            [JsonProperty(PropertyName = "id")]
            public long? Id { get; set; }

            [JsonProperty(PropertyName = "liked")]
            public bool Liked { get; set; }

            [JsonProperty(PropertyName = "admin")]
            public bool Admin { get; set; }
        }
        [Serializable]
        public class UserData
        {
            [JsonProperty(PropertyName = "country")]
            public string Country { get; set; }

            [JsonProperty(PropertyName = "locale")]
            public string Locale { get; set; }

            [JsonProperty(PropertyName = "age")]
            public AgeData Age { get; set; }

            [Serializable]
            public class AgeData
            {
                [JsonProperty(PropertyName = "min")]
                public int? Min { get; set; }

                [JsonProperty(PropertyName = "max")]
                public int? Max { get; set; }
            }
        }

    }
}
